from functools import cmp_to_key
n = 10005
fa = [i for i in range(n)]  # 父节点
a = [0 for _ in range(n)]  # 房子
b = [0 for _ in range(n)]  # 财产
num = [1 for _ in range(n)]  # 节点数量
vis = []


def find(x):
    if x != fa[x]:
        fa[x] = find(fa[x])
    return fa[x]


def merge(x, y):
    x, y = find(x), find(y)
    if x < y:
        x, y = y, x
    elif x == y:  # 注意同根的情况
        return
    fa[x] = fa[y]
    a[y] += a[x]
    b[y] += b[x]
    num[y] += num[x]


line = []
for _ in range(int(input())):
    l = list(map(int, input().split()))
    line.append(l)
    if l[-1]:
        a[l[0]] = l[-2]
        b[l[0]] = l[-1]


for l in line:
    vis.append(l[0])
    if l[1] != -1:
        vis.append(l[1])
        merge(l[0], l[1])
    if l[2] != -1:
        vis.append(l[2])
        merge(l[0], l[2])
    m = l[3]
    for i in range(m):
        vis.append(l[4+i])
        merge(l[4+i], l[0])
cnt = 0
tar = []

for i in vis:
    if i not in tar and i == find(i):
        cnt += 1
        tar.append(i)

tar.sort(key=lambda x: (-b[x]/num[x], x))  # 第二维度
print(cnt)
for i in tar:
    print(f'{i:04d} {num[i]} {a[i]/num[i]:.3f} {b[i]/num[i]:.3f}')
